package librus.cheeseChaser.util
{
	import feathers.system.DeviceCapabilities;
	
	import flash.display.Bitmap;
	import flash.utils.Dictionary;
	
	import starling.core.Starling;
	import starling.textures.Texture;
	import starling.textures.TextureAtlas;

	public class Assets
	{		
		[Embed(source="/../assets/atlas.png")]
		protected static const ATLAS_IMAGE:Class;
		
		[Embed(source="/../assets/atlas.xml",mimeType="application/octet-stream")]
		protected static const ATLAS_XML:Class;
		
		
		public static var TILE_SIZE:int;
		
		private static var gameTextures:Dictionary = new Dictionary();
		private static var gameTextureAtlas:TextureAtlas;		
	
		public static function init():void
		{
			trace(DeviceCapabilities.dpi);
			TILE_SIZE = 80;
		}
		public static function getAtlas():TextureAtlas
		{
			if (gameTextureAtlas == null)
			{
				var texture:Texture = getTexture("ATLAS_IMAGE");
				var xml:XML = XML(new ATLAS_XML);
				gameTextureAtlas = new TextureAtlas(texture, xml);
			}
			return gameTextureAtlas;
		}
		
		public static function getTexture(name:String):Texture
		{
			if (gameTextures[name] == undefined)
			{
				var bitmap:Bitmap = new Assets[name]();
				gameTextures[name] = Texture.fromBitmap(bitmap);
			}
			return gameTextures[name];
		}
	
	}
}